source('/home/jc148322/scripts/libraries/cool_functions.r')
library(SDMTools)

wd= '/home/jc148322/frog_declines/SDM/Pre_decline/bioclim_1_4_5_6_8_9_12_15_16_17_18_19/models/' #your /models/ directory
out.dir='/home/jc148322/frog_declines/SDM/Pre_decline/'

species=list.files(wd)

out=NULL
for (spp in species) { cat(spp, '\n')
	
	spp.dir=paste(wd, spp, '/output/',sep=''); setwd(spp.dir)
	results=read.csv('maxentResults.csv',as.is=TRUE)
	results=results[,grep('contribution',colnames(results))]
	out=rbind(out,results)

}

out=cbind(species,out)
setwd(out.dir)
write.csv(out,'bioclim_contribution.csv',row.names=FALSE)

